function varargout = geo_3(varargin)
% GEO_3 M-file for geo_3.fig
%      GEO_3, by itself, creates a new GEO_3 or raises the existing
%      singleton*.
%
%      H = GEO_3 returns the handle to a new GEO_3 or the handle to
%      the existing singleton*.
%
%      GEO_3('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GEO_3.M with the given input arguments.
%
%      GEO_3('Property','Value',...) creates a new GEO_3 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before geo_3_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to geo_3_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help geo_3

% Last Modified by GUIDE v2.5 16-Apr-2012 12:37:49

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @geo_3_OpeningFcn, ...
                   'gui_OutputFcn',  @geo_3_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before geo_3 is made visible.
function geo_3_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to geo_3 (see VARARGIN)

% Choose default command line output for geo_3
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes geo_3 wait for user response (see UIRESUME)
% uiwait(handles.figure1);

%if exist(strcat(data.param.direc,'/data.mat')) == 2
%    load (strcat(data.param.direc,'/data.mat'),'data');
%end
global data;
data.param.Gcierre = true;

if (~isempty(data.param.Gtype_shfunc))
    switch (data.param.Gtype_shfunc)
        case 1,
            set(handles.radio_constant,'Value',1.0);
            hObject = handles.axes1;
            imshow('images/ele_constant.png')
        case 2,
            set(handles.radio_linear,'Value',1.0);
            hObject = handles.axes1;
            imshow('images/ele_linear.png')
        case 3,
            set(handles.radio_cuadratic,'Value',1.0);
            hObject = handles.axes1;
            imshow('images/ele_cuadratic.png')
        case 4,
            set(handles.radio_custom,'Value',1.0);
            hObject = handles.axes1;
            imshow('images/ele_custom.png')
    end
else
    set(handles.radio_constant,'Value',1.0);
    hObject = handles.axes1;
    imshow('images/ele_constant.png');
end
% --- Outputs from this function are returned to the command line.
function varargout = geo_3_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes during object creation, after setting all properties.
function axes1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to axes1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: place code in OpeningFcn to populate axes1


% --- Executes on button press in radio_constant.
function radio_constant_Callback(hObject, eventdata, handles)
% hObject    handle to radio_constant (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radio_constant
if get(hObject,'Value')
    hObject = handles.axes1;
    imshow('images/ele_constant.png')
end


% --- Executes on mouse press over axes background.
function axes1_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to axes1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global data;
data.param.Gcierre = false;
%save(strcat(data.param.direc,'/data'), 'data');
close geo_3
%set(geo_1,'Visible','on') 
sctransp_1 

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global data;
data.param.Gcierre = false;

%genero las funciones de forma deseadas en los elementos
if get(handles.radio_constant,'Value')
    set(data.param,{'Gtype_shfunc'},num2cell(1));
elseif get(handles.radio_linear,'Value')
    set(data.param,{'Gtype_shfunc'},num2cell(2));
elseif get(handles.radio_cuadratic,'Value')
    set(data.param,{'Gtype_shfunc'},num2cell(3));
elseif get(handles.radio_custom,'Value')
    set(data.param,{'Gtype_shfunc'},num2cell(2));
    warndlg('Custom Shape Functions has not already implemented. Linear function has been selected by default');
end

%save(strcat(data.param.Gdirec,'/data'), 'data');
if (data.mesh.ndm == 1)
    close geo_3
    bc_1D
end
if (data.mesh.ndm == 2)
    close geo_3
    bc_2D
end

% --- Executes on button press in radio_linear.
function radio_linear_Callback(hObject, eventdata, handles)
% hObject    handle to radio_linear (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radio_linear
if get(hObject,'Value')
    hObject = handles.axes1;
    imshow('images/ele_linear.png')
end


% --- Executes on button press in radio_cuadratic.
function radio_cuadratic_Callback(hObject, eventdata, handles)
% hObject    handle to radio_cuadratic (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radio_cuadratic
if get(hObject,'Value')
    hObject = handles.axes1;
    imshow('images/ele_cuadratic.png')
end


% --- Executes on button press in radio_custom.
function radio_custom_Callback(hObject, eventdata, handles)
% hObject    handle to radio_custom (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radio_custom
if get(hObject,'Value')
    hObject = handles.axes1;
    imshow('images/ele_custom.png')
end


% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: delete(hObject) closes the figure
global data;
if (data.param.Gcierre)
    resp=questdlg('Está seguro que desea salir?','EduFEM');
    if strcmp(resp,'Yes')
        save(strcat(data.param.Gdirec,'/data'), 'data');
        delete(hObject);
    end
else
    delete(hObject);
end 

% --- Executes during object deletion, before destroying properties.
function figure1_DeleteFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


